/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package rg1calculatorapp;

/**
 *
 * @author apple
 */
public class Expression {
    
    private double num1;
    private double num2;
    private char sign;

    public Expression() {
    }

    public Expression(double num1, double num2) {
        this.num1 = num1;
        this.num2 = num2;
    }

    public Expression(double num1, double num2, char sign) {
        this.num1 = num1;
        this.num2 = num2;
        this.sign = sign;
    }

    public double getNum1() {
        return num1;
    }

    public void setNum1(double num1) {
        this.num1 = num1;
    }
    
    public void setNum1(String num1)
    {
        this.num1=Double.parseDouble(num1);
    }

    public double getNum2() {
        return num2;
    }

    public void setNum2(double num2) {
        this.num2 = num2;
    }
    
    public void setNum2(String num2)
    {
        this.num2=Double.parseDouble(num2);
    }

    public char getSign() {
        return sign;
    }

    public void setSign(char sign) {
        this.sign = sign;
    }
    
    public double getResult()
    {
        double result=0;
        switch(sign)
        {
            case '+':result=num1+num2;
            break;
            case '-':result=num1-num2;
            break;
            case '*':result=num1*num2;
            break;
            case '/':result=num1/num2;
            break;
        }
        return result;
    }
    
}
